package com.codewsq.exer;

import java.util.*;

public class DAO<T> {

    private Map<String, T> map;

    public DAO() {
        map = new HashMap<>();
    }

    public void save(String key, T value) {
        map.put(key, value);
    }

    public List<T> getDAO() {
        Collection<T> values = map.values();
        ArrayList<T> list = new ArrayList<>(values);
        return list;
    }

    public void update(String key, T value) {
        if (map.containsKey(key)) {
            map.put(key, value);
        }
    }

    public void remove(String key) {
        map.remove(key);
    }

}
